-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: Use world.key instead of world.id to generate entity PDA #58
base: main
Are you sure you want to change the base?
wip: Use world.key instead of world.id to generate entity PDA #58
Conversation
: FindEntityPda({ worldId, entityId: new BN(worldInstance.entities) }); | ||
let entityPda: PublicKey; | ||
if (seed !== undefined) { | ||
entityPda = FindEntityPda({ world, seed }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now the happy path, much faster to generate transactions
This PR seems old. Is it still an issue? |
Hello there, yes latest master still seem to have the issue: we always have to read the latest world.Id through a "World.fromAccountAddress" before creating any new entity (but seed-based entities may not need to do that in theory) |
Problem
When adding a new entity using seeds, we have to fetch the WorldId which can needs to be resolved from the onchain state. This means we have to do an RPC call for each transaction we are trying to prepare in those cases.
Solution
An easy solution is just to allow users to generate the Entity PDA from the worldPda instead, that way the users avoid unecessary lookups from the on-chain state when using entity seeds.
Notes
Also change the naming from "extraSeed" to "seed" in the entity API, since this seed effectively replace the "entity id", it's not an addition on top of it.